<h1>Search</h1>

<table width="100%">
	<tr>
		<td>{mm_alpha key="filter" base=$content.alpha_base}</td>
		<td>
			Genre
			<select>
				<option value="null">Select A Genre</option>
				<option value="null"></option>
			{foreach from=$genres item=g name=genres}
				<option value="{$g.id}" {if $g.id == $content.genre_id}selected{/if}>{$g.name}<!--&nbsp;&nbsp;&nbsp;[{$g.movie_count}]--></option>
			{/foreach}
			</select>&nbsp;
		</td>
		<form method="GET" action="index.php">
		<input type="hidden" name="what" value="mymovies">
		<input type="hidden" name="filter" value="{$content.filter}">
		<td align="right">
			<input type="text" name="search" value="{$content.search}">
			<input type="submit" value="Search"><br />
			<a href="index.php?what=mymovies&do=search">Advanced Search</a> | <a href="index.php?what=search&search={$content.search_term}">Reset Results</a>
		</td>
	</form>
	</tr>
</table>
<form method="POST" action="index.php" name="frm_search" id="frm_search">
<input type="hidden" name="what" value="mymovies">
<input type="hidden" name="do" value="add">
<table class="data_table" width="100%" cellpadding="5" cellspacing="0">
	<tr class="data_table_header">
		<td width="1%"><input type="checkbox" id="select_all" /></td>
		<td>Title</td>
		<td>Owners</td>
		<td>In your collection?</td>
		<td></td>
	</tr>
	{if $content.search}
		{foreach from=$content.search_results item=search}
			<tr class="{cycle values="data_table_row_1,data_table_row_2"}">
				<td><input type="checkbox" name="id[]" value="{$search.id}"></td>
				<td>{$search.title} ({$search.year}) {imdb url=$search.imdb_url}</td>
				<td>{$search.owners}</td>
				<td>{if $search.owned}yes{else}no{/if}</td>
				<td align="right" nowrap="nowrap">
					{if !$search.owned}<a href="index.php?what=mymovies&do=add&id={$search.id}">Add to collection</a> |
					<a href="index.php?what=wishlist&do=add&id={$search.id}">Add to wishlist</a> |{/if}
					<a href="index.php?what=movie&do=view&id={$search.id}">View</a> |
					<a href="javascript: movie_list_add({$search.id});">MARK</a>
				</td>
			</tr>
		{/foreach}
	{else}
		<tr>
			<td colspan="5" align="center">
				{if $search_term != ""}
					Could not find any movies under this name
				{else}
					A valid search term must be provided.
				{/if}
			</td>
		</tr>
	{/if}
</table>
</form>

{if $content.search}
	<img src="templates/{$config.smarty_template}/images/up_arrow.gif"> Do with selected: <a href="javascript: document.frm_search.submit();">Add to collection</a>
	{pagination pagination=$content.pagination}
{/if}
<script>init_select_all('frm_search');</script>
<br /><br />
<table>
	<tr>
		<td>{if $content.search_term !== ''}Cant find '<strong>{$content.search_term}</strong>'???{else}Cant find a movie???{/if} Try Adding it!</td>
	</tr>
	<form method="POST" action="index.php">
	<input type="hidden" name="what" value="movie">
	<input type="hidden" name="do" value="add">
	<tr>
		<td><input name="title" value="{$content.search_term}"> <input type="submit" value="Add Movie!"></td>
	</tr>
	</form>
</table>